{extend name=".././view/list.html" /}
{block name="jsset"}
{/block}
{block name="nav"}
<span class="layui-breadcrumb">
	<a href="">师生名单</a>
	<a href="">教师管理</a>
	<a><cite>教师列表</cite></a>
</span>
{/block}
{block name="search"}
<div class="layui-form-item">
	<label for="searchval" class="layui-form-label">
		关键字
	</label>
	<div class="layui-input-block">
		<input type="text" id="searchval" name="searchval" autocomplete="off" class="layui-input" placeholder="输入关键字并回车">
	</div>
</div>
<div class="layui-form-item">
	<label for="danwei_id" class="layui-form-label" style="height: 100%">单位</label>
	<div class="layui-input-block">
		<input type="radio" name="danwei_id" title="无" value="" lay-skin="primary" checked>
		{php} $schoollist = danweiJibie('校级', '区级');{/php}
		{volist name="schoollist" id="vo"}
		<input type="radio" name="danwei_id" title="{$vo.jiancheng}" value="{$vo.id}" lay-skin="primary">
		{/volist}
	</div>
</div>
<div class="layui-form-item">
	<label for="zhiwu_id" class="layui-form-label" style="height: 100%">职务</label>
	<div class="layui-input-block">
		<input type="radio" name="zhiwu_id" title="无" value="" lay-skin="primary" checked>
		{php} $category = categoryChildren(107);{/php}
		{volist name="category" id="vo"}
		<input type="radio" name="zhiwu_id" title="{$vo.title}" value="{$vo.id}" lay-skin="primary">
		{/volist}
	</div>
</div>
<div class="layui-form-item" style="margin-bottom: 0;">
	<label for="xueli_id" class="layui-form-label" style="height: 100%">学历</label>
	<div class="layui-input-block">
		<input type="radio" name="xueli_id" title="无" value="" lay-skin="primary" checked>
		{php} $category = categoryChildren(105);{/php}
		{volist name="category" id="vo"}
		<input type="radio" name="xueli_id" title="{$vo.title}" value="{$vo.id}" lay-skin="primary">
		{/volist}
	</div>
</div>
<div class="layui-form-item" style="margin-bottom: 0;">
	<label for="zhicheng_id" class="layui-form-label" style="height: 100%">学历</label>
	<div class="layui-input-block">
		<input type="radio" name="zhicheng_id" title="无" value="" lay-skin="primary" checked>
		{php} $category = categoryChildren(106);{/php}
		{volist name="category" id="vo"}
		<input type="radio" name="zhicheng_id" title="{$vo.title}" value="{$vo.id}" lay-skin="primary">
		{/volist}
	</div>
</div>
<div class="layui-form-item" style="margin-bottom: 0;">
	<label for="tuixiu" class="layui-form-label" style="height: 100%">是否退休</label>
	<div class="layui-input-block">
		<input type="radio" name="tuixiu" title="是" value="1" lay-skin="primary">
		<input type="radio" name="tuixiu" title="否" value="0" lay-skin="primary" checked="true">
	</div>
</div>
<div class="layui-form-item" style="text-align: right;">
	<button class="layui-btn" lay-filter="searchSubmit" lay-submit="">搜索</button>
</div>
{/block}
{block name="table"}
<table id="tabledemo" lay-filter="mytable" lay-size="sm"></table>
{/block}
{block name="myjs"}
<!-- 表格上面按钮模板 -->
<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-danger" lay-event="dels">
			<i class="iconfont">&#xe69d;</i> 批量删除
		</button>
		<button class="layui-btn" lay-event="add">
			<i class="iconfont">&#xe6b9;</i> 添加
		</button>
		<button class="layui-btn" lay-event="upload">
			<i class="iconfont">&#xe71d;</i> 导入数据
		</button>
		<button class="layui-btn" lay-event="download">
			<i class="iconfont">&#xe714;</i> 下载模板
		</button>
	</div>
</script>
<!-- 记录操作按钮模板 -->
<script type="text/html" id="barDemo">
	<a class="layui-btn-xs" lay-event="detail" title="查看"><i class="layui-icon layui-icon-search"></i></a>
	<a class="layui-btn-xs" lay-event="edit" title="编辑"><i class="layui-icon">&#xe642;</i></a>
  <a class="layui-btn-xs" lay-event="reset" title="密码重置"><i class="layui-icon layui-icon-password"></i></a>
	<a class="layui-btn-xs" lay-event="del" title="删除"><i class="layui-icon">&#xe640;</i></a>
</script>
<!-- 表格操作 -->
<script>
// 设置列
options.cols = [
	[ //表头
		{ type: 'checkbox', fixed: 'left' },
		{
			field: 'danwei_id',
			title: '单位',
			sort: true,
			templet: function(d) {
				var str = '';
				if (d.jsDanwei) {
					str = d.jsDanwei.jiancheng;
				}
				return str;
			}
		},
		{ field: 'xingming', title: '姓名', sort: true },
		{ field: 'sex', title: '性别', sort: true },
		{ field: 'phone', title: '手机号', sort: true },
		{
			field: "shengri",
			title: '周岁',
			sort: true,
			templet: function(d) {
				return d.age;
			}
		},
		{
			field: 'xueli_id',
			title: '学历',
			sort: true,
			templet: function(d) {
				var str = '';
				if (d.jsXueli) {
					str = d.jsXueli.title;
				}
				return str;
			}
		},
		{ field: 'biye', title: '毕业院校', sort: true },
		{
			field: 'worktime',
			title: '工龄',
			sort: true,
			templet: function(d) {
				return d.gongling;
			}
		},
		{ field: 'zhuanye', title: '专业', sort: true },
		{ field: 'status', title: '状态', templet: '#status', sort: true },
		{ field: 'id', title: '操作', toolbar: '#barDemo', minWidth: 140 }
	]
];

// 提交搜索条件后重载表格
layui.use(['table', 'cjgl'], function() {
	var table = layui.table
	cjgl = layui.cjgl;
	//表头工具栏事件
	table.on('toolbar(mytable)', function(obj) {
		switch (obj.event) {
			case 'dels':
				var checkStatus = table.checkStatus('mytable'); //idmytable 即为基础参数 id 对应的值
				cjgl.delAll(checkStatus, '/teacher/index/delete', 'mytable');
				break;
			case 'add':
				cjgl.add('添加教师', '/teacher/index/create', '', '', true);
				break;
			case 'upload':
				cjgl.add('导入教师', '/teacher/index/createall', '600', '300');
				break;
			case 'download':
				window.open("/teacher/index/downloadxls");
				break;
		};
	});

	//监听行工具条
	table.on('tool(mytable)', function(obj) {
		var data = obj.data; //获得当前行数据
		var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
		var tr = obj.tr; //获得当前行 tr 的DOM对象
		switch (layEvent) {
			case 'detail': // 查看
				cjgl.addTab(obj.data.xingming + '信息', '/teacher/index/read/' + obj.data.id, true);
				break;
			case 'del': // 删除
				cjgl.del(obj, "/teacher/index/delete");
				break;
			case 'edit': // 编辑
				cjgl.add('编辑教师', '/teacher/index/edit/' + obj.data.id, '', '', true);
				break;
			case 'reset': // 编辑
				cjgl.resetpassword(obj.data.xingming, "/teacher/index/resetpassword/" + obj.data.id);
				break;
		};
	});
});

</script>
{/block}
